<?php

class IndexController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
        // action body
    }
    
    public function dangkyAction()
    {
    	$this->view->title = 'Thêm người dùng';
    	$formThem = new Admin_Form_ThemNDForm();
    
    	$formThem->setMethod('post');
    	$formThem->setAction('/index/dangky/');
    
    	$formThem->addElement('submit','submit',array('label'=>'Thêm'));
    	$this->view->form = $formThem;
    	if($this->getRequest()->isPost())
    	{
    		if($formThem->isValid($_POST))
    		{
    			$data = $formThem->getValues();
    				
    			$tennd = $data['tennguoidung'];
    			$tendn = $data['tendangnhap'];
    			$email = $data['email'];
    			$matkhau = md5($data['matkhau']);
    			$khoa = $data['khoa'];
    			$quyenhan = $data['quyenhan'];
    				
    			$nguoidungMapper = Data_Model_NguoiDungMapper::getInstance();
    
    				
    
    				
    
    
    			$nguoidungObj = new Data_Model_NguoiDung();
    				
    
    			$nguoidungObj->setTennd($tennd);
    			$nguoidungObj->setEmail($email);
    			$nguoidungObj->setTendangnhap($tendn);
    			$nguoidungObj->setMatkhau($matkhau);
    			$nguoidungObj->setKhoa($khoa);
    			$nguoidungObj->setQuyenhan($quyenhan);
    
    
    			$nguoidung = $nguoidungMapper->save($nguoidungObj);
    
    			$this->_redirect('/admin/nguoidung/index');
    
    		}
    	}
    }


}

